package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.ICommunityPostMsgModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName CommunityPostMsgModel
 * @Description
 * @date 2016-6-30
 * @history 2016-6-30 author: description:
 */
public class CommunityPostMsgModel extends BaseModel implements ICommunityPostMsgModel, HttpWebServiceCallBack{


    public CommunityPostMsgModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

//    public CommunityPostMsgModel(CommunityPostMsgPresenter presenter) {
//        this.presenter = presenter;
//    }


    /**
     * 获取帖子消息
     *
     * @param pageNumber 页码
     * @param isRefresh  是否刷新
     */
    @Override
    public void doGetTopicNotice(int pageNumber, boolean isRefresh) {
        Map<String, String> getTopicNoticeParams = new HashMap<>();
        getTopicNoticeParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        getTopicNoticeParams.put("pageindex", Integer.toString(pageNumber));
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_GETNOTICELISTBYUSERID, getTopicNoticeParams, isRefresh, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if(getBasePresenter()!= null) getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
    }


}
